package com.itheima.task;

import java.util.concurrent.Callable;

/*同时开启两个线程，共同输出1-100之间的所有数字，并且将输出奇数的线程名称打印出来
* */
public class Number implements Callable<Integer> {
    private int number = 100;
    private Object obj = new Object();
    private int count =0;
    @Override
    public Integer call() throws Exception {
        while(true){
            synchronized (obj){

                if(number==0){break;}
                if(number%2!=0){
                    System.out.println(Thread.currentThread().getName()+"判断"+number+"是奇数");
                }else {
                    System.out.println(number);
                }
                count++;
                number--;
            }
        }

        return count;
    }

}
